<?php
/*
 * Created on 15 Nov, 2011
 *
 * To change the template for this generated file go to
 * Window - Preferences - PHPeclipse - PHP - Code Templates
 */

!defined(DRUPAL_ROOT) or exit("The library Lib_Glools_Mincs is running for drupal 7 system.");
module_exists('glools') or exit("Before you use Lib_Glools_Mincs you should enable glools module first.");

Lib_Glools_Load::loadFile('glools/base', 'lib');

class Lib_Glools_Loadinc extends Lib_Glools_Base{
	
    protected $module = '';
    
    protected $name = '';
    
    protected $type = '';
    
    public function __construct($module){
    	$this->setModule($module);
    }
    
    public function setModule($module){
    	if( !is_string($module) || false == module_exists($module) ){
    		return false;
    	}
        
        $this->module = $module;
    }
    
    public function getModule(){
    	return $this->module;
    }
    
    public function load($name, $type){
    	
        $incFile = $this->getPath($name, $type);
        
        if( false == $incFile ){
        	return false;
        }
        
        return require_once($incFile);
    }
    
    public function getPath($name, $type){
    	if( empty($this->module) ){
            return false;
        }
        
        $file = drupal_get_path('module', $this->module).'/inc_'.$type.'/'.$name.'.'.$type.'.inc';
        
        if( file_exists($file) ){
        	return $file;
        }
        return false;
    }
    
}